import { ref, watch } from 'vue'
import { useRoute } from 'vue-router'

export const useBreadCrum = () => {
    // 组合式获取路由信息对象route
    const route = useRoute()
    let breadList = ref<any>([])
    // console.log('watch外部')
    watch(route, newValue => {
        if (newValue.path === '/announce') {
            breadList.value = []
            return
        }
        breadList.value = newValue.matched.map(item => item.meta.title)
        // console.log('breadList',breadList.value)
        // console.log('watch内部')
    })

    return { breadList }
}
